Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request data to callback_context #3051

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Add request data to callback_context #3051

merged 3 commits into from
Oct 23, 2024

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Oct 22, 2024

Fix #2235

Add the following properties from flask.request to callback_context:

  • headers
  • cookies
  • path
  • remote
  • origin

triggered_inputs=callback_ctx.triggered_inputs,
ignore_register_page=True,
),
ctx_value,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to run this with a background task, I get a callback error of kombu.exceptions.EncodeError: Object of type Response is not JSON serializable. It works if I pop 'dash_response' and 'background_callback_manager' from this dict though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any automated tests for background tasks to help catch this...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah @T4rk1n I see you added one. Nice

@T4rk1n T4rk1n merged commit 0d9cd2c into dev Oct 23, 2024
3 checks passed
@T4rk1n T4rk1n deleted the fix/bg-cookies branch October 23, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flask contexts not available inside background callback
4 participants